<#assign ctx=springMacroRequestContext.contextPath />
<#include "/macro/publicMacro.ftl">
<#import "/macro/pagination.ftl" as Pagination>
<#import "/macro/FormItem.ftl" as Form>

<@header title="编辑标签">
    <link href="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.min.css" rel="stylesheet">
</@header>

<@body>
<h2 class="module-title">编辑标签</h2>

<div class="alert alert-primary" role="alert">
    <button class="btn btn-info" onclick="javascript: history.back(-1);return false;" >返回</button>
</div>

<form class="form-horizontal" id="cmsLabelForm" action="${ctx}/cmsLabel/save" method="post">
    <input type="hidden" name="id" value="${cmsLabel.id}"/>
    <@Form.FormItem name="tenantId" label="租户">
        <select class="form-control" name="tenantId" id="tenantId">
            <#list tenants as tenant>
                <option value="${tenant.id}" <#if tenant.id == cmsLabel.tenantId>selected</#if>>${tenant.description}</option>
            </#list>
        </select>
    </@Form.FormItem>

    <@Form.FormItem name="name" label="标签名称">
        <input type="text" class="form-control" name="name" id="name" aria-describedby="标签名称" value="${cmsLabel.name}">
    </@Form.FormItem>
    <@Form.FormItem name="categoryId" label="类目">
        <select class="form-control" name="categoryId" id="categoryId">
            <#list categoryList as category>
                <option value="${category.id}" <#if category.id == cmsLabel.categoryId>selected</#if>>${category.name}</option>
            </#list>
        </select>
    </@Form.FormItem>
    <@Form.FormItem name="enable" label="是否可用">
        <select class="form-control" name="enable" id="enable">
            <#list statusValues as status>
                <option value="${status}" <#if status == cmsLabel.status>selected</#if>>${status.desc}</option>
            </#list>
        </select>
    </@Form.FormItem>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary">提交</button>
        </div>
    </div>
</form>
</@body>

<@footer>
    <script src="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.full.min.js"></script>
    <script src="${ctx}/resource/common/js/jquery.validate.min.js"></script>
    <script src="${ctx}/resource/common/js/validate_zh.js"></script>

    <script type="text/javascript">
        $(function () {

        });

        $().ready(function() {
            $("#cmsLabelForm").validate({
                rules: {
                    id: {
                        required: true,
                        digits: true
                    },
                    name: "required" ,
                    categoryId: "required" ,
                    enable: {
                        required: true
                    },
                    tenantId: {
                        required: true,
                        digits: true
                    }
                }
            });
        });
    </script>
</@footer>